﻿define([
    "dojo/_base/declare"
    , "esri/layers/FeatureLayer"
    , "esri/renderers/SimpleRenderer"
], function (declare
    , FeatureLayer, SimpleRenderer) {
    var DivsLayer = declare([FeatureLayer], {

        constructor: function (options) {
            //              this.inherited(arguments, [options]);

            this._map = null; //地图对象

        }

        , _setMap: function (map, svg) {

            var g = this.inherited(arguments);

            this._map = map;

            return g;
        }

        , _unsetMap: function (map, svg) {
            this.inherited(arguments);

            this._map = null;
        }
        , setData: function (mapView, mapUtils, data, options = {}) {
            var me = this;
            if (!mapView) {
                return;
            }
            ;

            if (!mapUtils) {
                return;
            }
            ;

            if (!data) {
                return
            }
            ;

            var renderer = me.__getRenderer(mapView, mapUtils, data);
            me.setRenderer(renderer);
            me.refresh();
        },
        __getRenderer: function (mapView, mapUtils, data) {
            var renderer = null;
            switch (data.renderType) {
                case mapUtils.Enum.RenderType.SimpleRenderer:
                    renderer = mapUtils.getSimpleRenderer(mapView, data.symbol);
                    break;
                case mapUtils.Enum.RenderType.UniqueValueRenderer:
                    renderer = mapUtils.getUniqueValueRenderer(mapView, data.symbol);
                    break;
                case mapUtils.Enum.RenderType.ClassBreaksRenderer:
                    renderer = mapUtils.getClassBreaksRenderer(mapView, data.symbol);
                    break;
            };

            return renderer;
        }
    });
    return DivsLayer;
});